package com.zmn.oms.common.constant;

import com.zmn.common.constant.GlobalConsts;
import com.zmn.oms.common.vo.KVDict;

import java.util.Objects;

/**
 * 类描述：ERP常量值定义
 * @author heciqi
 * @date 2020/2/18 16:22
 */
public class ErpConsts {

    //订单发票类型 1纸质发票；2电子发票
    public final static int ORDER_INVOICE_TYPE_PAP = 1;
    public final static int ORDER_INVOICE_TYPE_ELE = 2;

    //发票billType 1纸质发票；2电子发票
    public final static int ORDER_INVOICE_BILL_TYPE_WORK = 1;
    public final static int ORDER_INVOICE_BILL_TYPE_REFUND = 2;
    public final static int ORDER_INVOICE_BILL_TYPE_SETTLEMENT = 3;

    //开票状态 1申请中，2已开具，3拒绝，4开具中，5开具失败，6,已冲销，7已作废
    public final static int INVOICE_STATUS_APPLYING = 1;
    public final static int INVOICE_STATUS_ISSUED = 2;
    public final static int INVOICE_STATUS_REFUSE = 3;
    public final static int INVOICE_STATUS_ISSUING = 4;
    public final static int INVOICE_STATUS_ISSUE_FAILED = 5;
    public final static int INVOICE_STATUS_REVERSED = 6;
    public final static int INVOICE_STATUS_ABOLISHED = 7;

    // 结算状态

    /**
     * 费用结算状态，1-未参与结算
     */
    public static final int NO_STATEMENT = 1;

    /**
     * 费用结算状态，2-已经参与结算
     */
    public static final int ALREADY_STATEMENT = 2;



    public static KVDict<Integer> getInvoiceType(int type) {
        switch (type) {
            case ORDER_INVOICE_TYPE_PAP:
                return KVDict.<Integer>builder().value(ORDER_INVOICE_TYPE_PAP).text("纸质发票").disabled(false).build();
            case ORDER_INVOICE_TYPE_ELE:
                return KVDict.<Integer>builder().value(ORDER_INVOICE_TYPE_ELE).text("电子发票").disabled(false).build();
            default:
                return null;
        }
    }

    public static String getBillTypeName(int type) {
        switch (type) {
            case ORDER_INVOICE_BILL_TYPE_WORK:
                return "工单";
            case ORDER_INVOICE_BILL_TYPE_REFUND:
                return "退款单";
            case ORDER_INVOICE_BILL_TYPE_SETTLEMENT:
                return "结算单";
            default:
                return "未知类型";
        }
    }

    public static String getInvoiceStatusName(int type) {
        switch (type) {
            case INVOICE_STATUS_APPLYING:
                return "申请中";
            case INVOICE_STATUS_ISSUED:
                return "已开具";
            case INVOICE_STATUS_REFUSE:
                return "已拒绝";
            case INVOICE_STATUS_ISSUING:
                return "开具中";
            case INVOICE_STATUS_ISSUE_FAILED:
                return "开具失败";
            case INVOICE_STATUS_REVERSED:
                return "已冲销";
            case INVOICE_STATUS_ABOLISHED:
                return "已作废";
            default:
                return "未知类型";
        }
    }

    public static String getStatementStatus(Integer status){
        if (Objects.isNull(status)) {
            return "未结算";
        }
        switch (status) {
            case GlobalConsts.YES:
                return "已结算";
            default:
                return "未结算";
        }
    }
}